package com.mcxx.modules.statistics.service.read;

import com.mcxx.modules.statistics.dao.read.StatisStatisItemReadDao;
import com.mcxx.modules.statistics.dto.*;
import com.mcxx.modules.statistics.entity.SubApprovalBuFaEntity;
import com.mcxx.util.Constant;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@TaTransactional(readOnly = true)
public class StatisticReadService {
    @Autowired
    private StatisStatisItemReadDao statisStatisItemReadDao;

    public List<SubStatisticsDTO> getCitySubsistenceComp(String areaCode, List<Integer> levels, String month,
                                                         Integer precision) {
        if(Integer.parseInt(month)>=202001){
            return statisStatisItemReadDao.getCitySubsistenceComp(areaCode, levels, month,
                    Constant.StatisBusinessCode.CITY_DIBAO, precision);
        }else{
            return statisStatisItemReadDao.getCitySubsistenceCompOld(areaCode, levels, month,
                    Constant.StatisBusinessCode.CITY_DIBAO, precision);
        }
    }


    public List<SubStatisticsDTO> getCountrySubsistenceComp(String areaCode, List<Integer> levels, String month,
                                                            Integer precision) {
        if(Integer.parseInt(month)>=202001){
            return statisStatisItemReadDao.getCountrySubsistenceComp(areaCode, levels, month,
                    Constant.StatisBusinessCode.COUNTY_DIBAO, precision);
        }else{
            return statisStatisItemReadDao.getCountrySubsistenceCompOld(areaCode, levels, month,
                    Constant.StatisBusinessCode.COUNTY_DIBAO, precision);
        }
    }

    public List<SubRevealDTO> getCitySubReveal(String areaCode, List<Integer> levels, String month) {
        return statisStatisItemReadDao.getCitySubReveal(areaCode, levels, month,
                Constant.StatisBusinessCode.CITY_DIBAO_DOC);
    }

    public List<SubRevealDTO> getCountrySubReveal(String areaCode, List<Integer> levels, String month) {
        if(Integer.parseInt(month)>=202001) {
            return statisStatisItemReadDao.getCountrySubReveal(areaCode, levels, month,
                    Constant.StatisBusinessCode.COUNTY_DIBAO_DOC);
        }
        else{
            return statisStatisItemReadDao.getCountrySubRevealOld(areaCode, levels, month,
                    Constant.StatisBusinessCode.COUNTY_DIBAO_DOC);
        }
    }


    public List<PovertyStatisticsDTO> getCityPovertyComp(String areaCode, List<Integer> levels, String month) {
        if(Integer.parseInt(month)>=202001){
            return statisStatisItemReadDao.getCityPovertyComp(areaCode, levels, month,
                    Constant.StatisBusinessCode.TEKUN);
        }else{
            return statisStatisItemReadDao.getCityPovertyCompOld(areaCode, levels, month,
                    Constant.StatisBusinessCode.TEKUN);
        }
    }


    public List<PovertyStatisticsDTO> getCountryPovertyComp(String areaCode, List<Integer> levels, String month) {
        if(Integer.parseInt(month)>=202001){
            return statisStatisItemReadDao.getCountryPovertyComp(areaCode, levels, month,
                    Constant.StatisBusinessCode.TEKUN);
        }else{
            return statisStatisItemReadDao.getCountryPovertyCompOld(areaCode, levels, month,
                    Constant.StatisBusinessCode.TEKUN);
        }
    }

    public List<TempStatisDTO> getTemp(String areaCode, List<Integer> levels, String month, int precision) {
        if(Integer.parseInt(month)>=202001){
            return statisStatisItemReadDao.getTemp(areaCode, levels, month,
                    Constant.StatisBusinessCode.LINSHI, precision);
        }else{
            return statisStatisItemReadDao.getTempOld(areaCode, levels, month,
                    Constant.StatisBusinessCode.LINSHI, precision);
        }
    }

    public List<PovertyRevealDTO> getCityPoverty(String areaCode, List<Integer> levels, String month) {
        return statisStatisItemReadDao.getCityPovertyReveal(areaCode, levels, month,
                Constant.StatisBusinessCode.CITY_TEKUN_DOC);
    }

    public List<PovertyRevealDTO> getCountryPovertyReveal(String areaCode, List<Integer> levels, String month) {
        if(Integer.parseInt(month)>=202001) {
            return statisStatisItemReadDao.getCountryPovertyReveal(areaCode, levels, month,
                    Constant.StatisBusinessCode.COUNTY_TEKUN_DOC);
        }
        else{
            return statisStatisItemReadDao.getCountryPovertyRevealOld(areaCode, levels, month,
                    Constant.StatisBusinessCode.COUNTY_TEKUN_DOC);
        }
    }

    public List<SubApprovalDTO> getCitySubSummary(String areaCode, Integer level, Integer validCodeLen, String zeros,
                                                         String month) {
        return statisStatisItemReadDao.getCitySubSummary(areaCode, level, validCodeLen, zeros, month);
    }

    public List<SubApprovalDTO> getCountrySubSummary(String areaCode, Integer level, Integer validCodeLen, String zeros,
                                                     String month) {
        return statisStatisItemReadDao.getCountrySubSummary(areaCode, level, validCodeLen, zeros, month);
    }

    public List<SubApprovalBuFaEntity> getSubSummaryBuFa(String areaCode, Integer level, Integer validCodeLen, String zeros,
                                                         String month, String standType) {
        return statisStatisItemReadDao.getSubSummaryBuFa(areaCode, level, validCodeLen, zeros, month, standType);
    }

    public List<PovertyApprovalDTO> getPovertySummary(String areaCode, Integer level, Integer validCodeLen, String zeros,
                                                     String month, String standType) {
        return statisStatisItemReadDao.getPovertySummary(areaCode, level, validCodeLen, zeros, month, standType);
    }

    public List<PovertyApprovalDTO> getCityPovertySummaryBasic(String areaCode, Integer level, Integer validCodeLen,
                                                               String zeros, String month) {
        return statisStatisItemReadDao.getCityPovertySummaryBasic(areaCode, level, validCodeLen, zeros, month);
    }

    public List<PovertyApprovalDTO> getCountryPovertySummaryBasic(String areaCode, Integer level, Integer validCodeLen,
                                                                  String zeros, String month) {
        return statisStatisItemReadDao.getCountryPovertySummaryBasic(areaCode, level, validCodeLen, zeros, month);
    }

    public List<PovertyApprovalDTO> getPovertySummarySalary(String areaCode, Integer level, Integer validCodeLen,
                                                            String zeros, String month, String standType) {
        return statisStatisItemReadDao.getPovertySummarySalary(areaCode, level, validCodeLen, zeros, month, standType);
    }

    public List<TempApprovalDTO> getTempSummary(String areaCode, Integer validCodeLen, String zeros, String monthStart,
                                                String monthEnd, Integer level) {
        return statisStatisItemReadDao.getTempSummary(areaCode, validCodeLen, zeros, monthStart, monthEnd, level);
    }

    public List<CityPovertyFamilyDynamicDTO> getCityPovertyFamilyDynamic(String areaCode, Integer level, List<Integer> levels, String month,String standType, String bizType) {
        return statisStatisItemReadDao.getCityPovertyFamilyDynamic(areaCode, level, levels, month, standType, bizType);
    }

    public List<MinLivingDetailDTO> getMiniLivingAuditSummary(String areaCode,
                                                                     String month, String standType) {
        return statisStatisItemReadDao.getMiniLivingAuditSummary(areaCode, month, standType);
    }


    public List<?> getDynamicFamilyWatch(String validCode, List<Integer> levels, Integer validCodeLen, String zeros, String bizType, String month) {
        return statisStatisItemReadDao.getDynamicFamilyWatch(validCode, levels, validCodeLen, zeros, bizType, month);
    }
}
